/*
' Copyright (c) 2011 DotNetNuke Corporation
'  All rights reserved.
' 
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
' 
*/

using System.Collections.Generic;
//using System.Xml;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search;
using DotNetNuke.Modules.PersonalAssistants.Data;
using DotNetNuke.Common.Utilities;

namespace DotNetNuke.Modules.PersonalAssistants.Components
{

    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The Controller class for PersonalAssistants
    /// </summary>
    /// -----------------------------------------------------------------------------

    //uncomment the interfaces to add the support.
    public class FeatureController //: IPortable, ISearchable, IUpgradeable
    {

        #region Public Methods
        /// <summary>
        /// This method will insert a guestbook entry to the system
        /// </summary>
        /// <param name="oInfo">The hydrated information object</param>
        public void InsertPAProfile(PersonalAssistantProfile oInfo)
        {
            
            DataProvider.Instance().InsertPAProfile(oInfo);
        }
        public void UpdatePAProfile(PersonalAssistantProfile oInfo)
        {
            DataProvider.Instance().UpdatePAProfile(oInfo);
        }



        /// <summary>
        /// This method will approve a guestbook entry
        /// </summary>
        /// <param name="moduleId">The id of the module used to modify the entries</param>
        /// <param name="entryId">The id of the entry</param>
        public void ApprovePAProfile(int moduleId, int entryId)
        {
            
            DataProvider.Instance().ApprovePAProfile(moduleId, entryId);
        }
        /// <summary>
        /// THis method will delete a guestbook entry
        /// </summary>
        /// <param name="moduleId">The id of the module used to delete the entries</param>
        /// <param name="entryId">The id of the entry</param>
        public void DeletePAProfile(int moduleId, int entryId)
        {
            DataProvider.Instance().DeletePAProfile(moduleId, entryId);
        }
        /// <summary>
        /// This method will get the listing of all approved entries
        /// </summary>
        /// <param name="moduleId">The instance to get entries for</param>
        /// <returns>The hydrated collection of information objects</returns>
        public List<PersonalAssistantProfile> GetApprovedEntries(int moduleId)
        {
            return CBO.FillCollection<PersonalAssistantProfile>(DataProvider.Instance().GetApprovedEntries(moduleId));
        }
        /// <summary>
        /// This method will get the listing of all entries
        /// </summary>
        /// <param name="moduleId">The instance to get entries for</param>
        /// <returns>The hydrated collection of information objects</returns>
        public List<PersonalAssistantProfile> GetAllEntries(int moduleId)
        {
            return CBO.FillCollection<PersonalAssistantProfile>(DataProvider.Instance().GetAllEntries(moduleId));
        }
        public List<PersonalAssistantProfile> SelectPAProfiles(int moduleId, string PALocation)
        {
            return CBO.FillCollection<PersonalAssistantProfile>(DataProvider.Instance().SelectPAProfiles(moduleId, PALocation));
        }
        public PersonalAssistantProfile GetPAProfile(int moduleId, int EntryId)
        {
            return CBO.FillObject<PersonalAssistantProfile>(DataProvider.Instance().GetPAProfile(moduleId, EntryId));

        }
        public PersonalAssistantProfile GetPAProfileByUsername(int moduleId, string username)
        {
            return CBO.FillObject<PersonalAssistantProfile>(DataProvider.Instance().GetPAProfileByUsername(moduleId, username));

        }
        #endregion


        
        
        #region Optional Interfaces

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be exported</param>
        /// -----------------------------------------------------------------------------
        public string ExportModule(int ModuleID)
        {
            //string strXML = "";

            //List<PersonalAssistantsInfo> colPersonalAssistantss = GetPersonalAssistantss(ModuleID);
            //if (colPersonalAssistantss.Count != 0)
            //{
            //    strXML += "<PersonalAssistantss>";

            //    foreach (PersonalAssistantsInfo objPersonalAssistants in colPersonalAssistantss)
            //    {
            //        strXML += "<PersonalAssistants>";
            //        strXML += "<content>" + DotNetNuke.Common.Utilities.XmlUtils.XMLEncode(objPersonalAssistants.Content) + "</content>";
            //        strXML += "</PersonalAssistants>";
            //    }
            //    strXML += "</PersonalAssistantss>";
            //}

            //return strXML;

            throw new System.NotImplementedException("The method or operation is not implemented.");
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        /// <param name="Content">The content to be imported</param>
        /// <param name="Version">The version of the module to be imported</param>
        /// <param name="UserId">The Id of the user performing the import</param>
        /// -----------------------------------------------------------------------------
        public void ImportModule(int ModuleID, string Content, string Version, int UserID)
        {
            //XmlNode xmlPersonalAssistantss = DotNetNuke.Common.Globals.GetContent(Content, "PersonalAssistantss");
            //foreach (XmlNode xmlPersonalAssistants in xmlPersonalAssistantss.SelectNodes("PersonalAssistants"))
            //{
            //    PersonalAssistantsInfo objPersonalAssistants = new PersonalAssistantsInfo();
            //    objPersonalAssistants.ModuleId = ModuleID;
            //    objPersonalAssistants.Content = xmlPersonalAssistants.SelectSingleNode("content").InnerText;
            //    objPersonalAssistants.CreatedByUser = UserID;
            //    AddPersonalAssistants(objPersonalAssistants);
            //}

            throw new System.NotImplementedException("The method or operation is not implemented.");
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchItems implements the ISearchable Interface
        /// </summary>
        /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param>
        /// -----------------------------------------------------------------------------
        public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
        {
            //SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();

            //List<PersonalAssistantsInfo> colPersonalAssistantss = GetPersonalAssistantss(ModInfo.ModuleID);

            //foreach (PersonalAssistantsInfo objPersonalAssistants in colPersonalAssistantss)
            //{
            //    SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objPersonalAssistants.Content, objPersonalAssistants.CreatedByUser, objPersonalAssistants.CreatedDate, ModInfo.ModuleID, objPersonalAssistants.ItemId.ToString(), objPersonalAssistants.Content, "ItemId=" + objPersonalAssistants.ItemId.ToString());
            //    SearchItemCollection.Add(SearchItem);
            //}

            //return SearchItemCollection;

            throw new System.NotImplementedException("The method or operation is not implemented.");
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeModule implements the IUpgradeable Interface
        /// </summary>
        /// <param name="Version">The current version of the module</param>
        /// -----------------------------------------------------------------------------
        public string UpgradeModule(string Version)
        {
            throw new System.NotImplementedException("The method or operation is not implemented.");
        }

        #endregion

    }

}
